/*
// Definition for a Node.
class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};
*/

class Solution {
    public:
        vector<vector<int>> levelOrder(Node* root) {
            vector<vector<int>> ret;
            if(root==nullptr) return ret;
            queue<Node*> q;
            q.push(root);
            while(!q.empty())
            {
                int sz = q.size();
                vector<int> tmp;
                for(int i=0;i<sz;i++)
                {
                    Node* t  =q.front();
                    q.pop();
                    tmp.push_back(t->val);
                    for(Node* child:t->children)
                    {
                        if(child!=NULL)
                            q.push(child);
                    }
                }
                ret.push_back(tmp);
            }
            return ret;
        }
    };

    /**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
    public:
        ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
            ListNode* cur1=l1,*cur2=l2;
            ListNode* newhead =new ListNode(0);
            ListNode* prev=newhead;
            int t =0;
            while(cur1||cur2||t)
            {
                if(cur1)
                {
                    t+=cur1->val;
                    cur1=cur1->next;
                }
                if(cur2)
                {
                    t+=cur2->val;
                    cur2=cur2->next;
                }
                prev->next = new ListNode(t%10);
                prev=prev->next;
                t/=10;
            }
            prev = newhead->next;
            delete newhead;
            return prev;
        }
    };